package com.serenegiant.usb.common;

import android.app.Activity;

import com.serenegiant.usb.UVCCamera;
import com.serenegiant.usb.widget.CameraViewInterface;

/**
 * Created by vcom on 2020-6-18.
 */

public class UVCCameraHandlerIR extends AbstractUVCCameraHandlerIR {

    /**
     * create UVCCameraHandler, use MediaVideoEncoder, try MJPEG, default bandwidth
     * @param parent
     * @param cameraView
     * @param width
     * @param height
     * @return
     */
    public static final UVCCameraHandlerIR createHandler(
            final Activity parent, final CameraViewInterface cameraView,
            final int width, final int height) {

        return createHandler(parent, cameraView, 1, width, height, UVCCamera.FRAME_FORMAT_MJPEG, UVCCamera.DEFAULT_BANDWIDTH);
    }

    /**
     * create UVCCameraHandlerIR, use MediaVideoEncoder, try MJPEG
     * @param parent
     * @param cameraView
     * @param width
     * @param height
     * @param bandwidthFactor
     * @return
     */
    public static final UVCCameraHandlerIR createHandler(
            final Activity parent, final CameraViewInterface cameraView,
            final int width, final int height, final float bandwidthFactor) {

        return createHandler(parent, cameraView, 1, width, height, UVCCamera.FRAME_FORMAT_MJPEG, bandwidthFactor);
    }

    /**
     * create UVCCameraHandlerIR, try MJPEG, default bandwidth
     * @param parent
     * @param cameraView
     * @param encoderType 0: use MediaSurfaceEncoder, 1: use MediaVideoEncoder, 2: use MediaVideoBufferEncoder
     * @param width
     * @param height
     * @return
     */
    public static final UVCCameraHandlerIR createHandler(
            final Activity parent, final CameraViewInterface cameraView,
            final int encoderType, final int width, final int height) {

        return createHandler(parent, cameraView, encoderType, width, height, UVCCamera.FRAME_FORMAT_MJPEG, UVCCamera.DEFAULT_BANDWIDTH);
    }

    /**
     * create UVCCameraHandlerIR, default bandwidth
     * @param parent
     * @param cameraView
     * @param encoderType 0: use MediaSurfaceEncoder, 1: use MediaVideoEncoder, 2: use MediaVideoBufferEncoder
     * @param width
     * @param height
     * @param format either UVCCamera.FRAME_FORMAT_YUYV(0) or UVCCamera.FRAME_FORMAT_MJPEG(1)
     * @return
     */
    public static final UVCCameraHandlerIR createHandler(
            final Activity parent, final CameraViewInterface cameraView,
            final int encoderType, final int width, final int height, final int format) {

        return createHandler(parent, cameraView, encoderType, width, height, format, UVCCamera.DEFAULT_BANDWIDTH);
    }

    /**
     * create UVCCameraHandlerIR
     * @param parent
     * @param cameraView
     * @param encoderType 0: use MediaSurfaceEncoder, 1: use MediaVideoEncoder, 2: use MediaVideoBufferEncoder
     * @param width
     * @param height
     * @param format either UVCCamera.FRAME_FORMAT_YUYV(0) or UVCCamera.FRAME_FORMAT_MJPEG(1)
     * @param bandwidthFactor
     * @return
     */
    public static final UVCCameraHandlerIR createHandler(
            final Activity parent, final CameraViewInterface cameraView,
            final int encoderType, final int width, final int height, final int format, final float bandwidthFactor) {

        final CameraThread thread = new CameraThread(UVCCameraHandlerIR.class, parent, cameraView, encoderType, width, height, format, bandwidthFactor);
        thread.start();
        return (UVCCameraHandlerIR)thread.getHandler();
    }

    protected UVCCameraHandlerIR(final CameraThread thread) {
        super(thread);
    }

    @Override
    public void startPreview(final Object surface) {
        super.startPreview(surface);
    }

//	@Override
//	public void captureStill() {
//		super.captureStill();
//	}

    @Override
    public void captureStill(final String path,OnCaptureListener listener) {
        super.captureStill(path,listener);
    }

    @Override
    public void startCameraFoucs() {
        super.startCameraFoucs();
    }
}
